package cn.javadog.smartbreeding.record.controller;

import cn.javadog.smartbreeding.core.dto.BillDTO;
import cn.javadog.smartbreeding.core.service.BillService;
import cn.javadog.smartbreeding.core.config.util.Ret;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 余勇
 */
@Api(tags = "账单票据")
@RestController
@RequestMapping("bills")
public class BillController {

	@Autowired
	private BillService billService;

	@ApiOperation("票据录入")
	@PostMapping
	public Ret save(@RequestBody BillDTO dto) {
		return Ret.ok(billService.save(dto));
	}

	@ApiOperation("价格计算")
	@PostMapping("compute")
	public Ret compute(@RequestBody BillDTO dto) {
		return Ret.ok(billService.compute(dto));
	}
}
